package com.yanfan.energy.mapper;


import com.yanfan.energy.domain.Workshop;
import com.yanfan.energy.domain.statist.DateStatistics;
import com.yanfan.energy.domain.statist.DayEnergyStatistics;
import com.yanfan.energy.domain.statist.EnvironmentStatics;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

/**
 * 车间表(Workshop)表数据库访问层
 *
 * @author makejava
 * @since 2022-09-26 13:49:22
 */
@Repository
public interface WorkshopDao {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    Workshop queryById(Integer id);

    /**
     * 查询指定行数据
     *
     * @param workshop 查询条件
     * @param pageable 分页对象
     * @return 对象列表
     */
    List<Workshop> queryAllByLimit(Workshop workshop, @Param("pageable") Pageable pageable);

    /**
     * 统计总行数
     *
     * @param workshop 查询条件
     * @return 总行数
     */
    long count(Workshop workshop);

    /**
     * 新增数据
     *
     * @param workshop 实例对象
     * @return 影响行数
     */
    int insert(Workshop workshop);

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<Workshop> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<Workshop> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<Workshop> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<Workshop> entities);

    /**
     * 修改数据
     *
     * @param workshop 实例对象
     * @return 影响行数
     */
    int update(Workshop workshop);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(Integer id);

    /**
     * 车间能耗分析-耗水统计-冷却水统计
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findCoolingStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-耗水统计-自来水统计
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findTapStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-耗水统计-软化水统计
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findSofteningStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-耗气统计-压缩空气
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findCompressStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-耗水统计-天然气
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findNaturalStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-耗水统计-蒸汽
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findVapourStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-时段用电总量-尖电
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findSpikesStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-时段用电总量-峰电
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findPeaksStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-时段用电总量-平电
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findParityStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-时段用电总量-谷电
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findLowEbbStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-空调热能
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findAirConditioner(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-能耗排名
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/28 9:38
     */
    List<DateStatistics> findEnergyStatistics(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 车间能耗分析-车间能耗对比
     *
     * @param workshopId
     * @param type
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/28 10:43
     */
    List<DateStatistics> findWorkshopComparison(@Param("workshopId") Integer workshopId, @Param("type") Integer type, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 能耗总分析-车间总能耗统计
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/28 16:12
     */
    List<DateStatistics> findTotalCost(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 能源介质总费用-电能
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/29 11:49
     */
    List<DateStatistics> findTotalCostByElectric(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 能源介质总费用-压缩空气
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/29 11:49
     */
    List<DateStatistics> findTotalCostByCompressedAir(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 能源介质总费用-热能
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/29 11:49
     */
    List<DateStatistics> findTotalCostByThermal(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 能源介质总费用-水能
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/29 11:49
     */
    List<DateStatistics> findTotalCostByWater(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 查询所有的车间
     *
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/30 10:24
     */
    List<DateStatistics> findAllWorkShop();

    /**
     * 根据楼栋查询车间
     *
     * @param bId
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/10/8 16:19
     */
    List<DateStatistics> findAllWorkShopByBuildId(Integer bId);

    /**
     * 查看车间温度
     *
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.EnvironmentStatics>
     * @author caijinkang
     * @date 2022/10/8 15:33
     */
    List<EnvironmentStatics> findTemperature();

    /**
     * 查看车间电监控
     *
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.EnvironmentStatics>
     * @author caijinkang
     * @date 2022/10/9 10:04
     */
    List<EnvironmentStatics> findElectricity();

    /**
     * 查看用电能耗
     *
     * @param datetime
     * @param begin
     * @param end
     * @return java.util.List<com.ruoyi.common.core.domain.model.DateStatistics>
     * @author caijinkang
     * @date 2023/2/21 14:54
     */
    List<DateStatistics> findCountElectricity(@Param("datetime") String datetime, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 设备总能耗
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @param tid
     * @return java.util.List<com.ruoyi.common.core.domain.model.DateStatistics>
     * @author caijinkang
     * @date 2023/2/21 14:54
     */
    List<DateStatistics> findEquipmentEnergy(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end, @Param("tId") Integer tid);

    /**
     * 查看单个车间
     *
     * @param id
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/10/13 15:29
     */
    List<DateStatistics> queryByWorkId(Long id);

    /**
     * 根据楼栋id查询车间信息
     *
     * @param buildingId
     * @return java.util.List<com.ruoyi.common.core.domain.model.DateStatistics>
     * @author caijinkang
     * @date 2023/5/23 15:09
     */
    List<DateStatistics> findWorkshopByBuildingId(@Param("buildingId") Integer buildingId);

    /**
     * 根据楼层id查询车间
     *
     * @param floorId
     * @return java.util.List<com.ruoyi.common.core.domain.model.DateStatistics>
     * @author caijinkang
     * @date 2023/5/23 15:09
     */
    List<DateStatistics> findWorkshopByFloorId(@Param("floorId") Integer floorId);

    /**
     * 查询1-11的能源类型数据
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<com.ruoyi.common.core.domain.model.DateStatistics>
     * @author caijinkang
     * @date 2022/10/17 12:12
     */
    List<DateStatistics> findAllEnergyByNo(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 查询楼栋信息
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/10/17 13:25
     */
    List<DateStatistics> findAllEnergyByBuildingId(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 查询车间信息
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/10/17 13:05
     */
    List<DateStatistics> findAllEnergyByWorkshopId(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 查询能源1-11的不算价格数据
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/10/17 13:05
     */
    List<DateStatistics> findAllEnergyByNoMo(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 根据车间id查询所有设备
     *
     * @param workshopId
     * @return java.util.List<com.ruoyi.common.core.domain.entity.Workshop>
     * @author caijinkang
     * @date 2022/10/19 17:49
     */
    List<Workshop> findAllDeviceByWorkshopId(Integer workshopId);

    /**
     * 车间能耗分析-所有能耗统计
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DateStatistics>
     * @author caijinkang
     * @date 2022/9/27 13:41
     */
    List<DateStatistics> findEnergyStatisticsByAll(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 查询当日能耗价格：总耗电，总耗气，总水
     *
     * @param workshopId
     * @return io.github.jhipster.sample.sansheng.tool.statistics.DayEnergyStatistics
     * @author caijinkang
     * @date 2022/10/21 10:36
     */
    DayEnergyStatistics findEnergyByTodayAndPrice(@Param("workshopId") Long workshopId);

    /**
     * 查询当日能耗：总耗电，总耗气，总水
     *
     * @param workshopId
     * @return io.github.jhipster.sample.sansheng.tool.statistics.DayEnergyStatistics
     * @author caijinkang
     * @date 2022/10/21 10:36
     */
    DayEnergyStatistics findEnergyByToday(@Param("workshopId") Long workshopId);

    /**
     * 单位用电用水用气
     *
     * @param datetime
     * @param workshopId
     * @param begin
     * @param end
     * @return java.util.List<io.github.jhipster.sample.sansheng.tool.statistics.DayEnergyStatistics>
     * @author caijinkang
     * @date 2022/10/21 14:01
     */
    List<DayEnergyStatistics> findUnitOfElectricity(@Param("datetime") String datetime, @Param("workshopId") Long workshopId, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 根据车间名称查询
     *
     * @param shopname
     * @return
     */
    Workshop findWorkshopByshopName(String shopname);

    /**
     * 根据楼层id查询车间信息
     *
     * @param buildingId
     * @return java.util.List<com.ruoyi.common.core.domain.entity.Workshop>
     * @author caijinkang
     * @date 2022/10/19 17:49
     */
    List<Workshop> findAllWorkshopByFloorId(@Param("buildingId") Integer buildingId);

    /**
     * 根据部门id查询车间信息
     *
     * @param deptId
     * @return java.util.List<com.ruoyi.common.core.domain.entity.Workshop>
     * @author caijinkang
     * @date 2023/5/6 10:12
     */
    List<Workshop> findAllWorkshopByDeptId(@Param("deptId") Integer deptId, @Param("buildingId") Integer buildingId);

}

